<div class="col-lg-12">
    <div class="widget clear">
        <div class="widget-heading clearfix">
            <h3 class="widget-title pull-left">添加权限</h3>
        </div>
    </div>
</div>
<div class="col-md-12">
    <form id="addForm" action="{:url('admin/auth/add')}" method="post">
        <div class="form-group">
            <label>所属菜单</label>
            <select name="pid" class="form-control">
                <option value="0">一级菜单</option>
                {foreach $auth as $val}
                <option value="{$val->id}">{$val->name}</option>
                {/foreach}
            </select>
        </div>
        <div class="form-group">
            <label>权限名称</label>
            <input type="text" placeholder="权限名称" name="name" class="form-control">
        </div>
        <div class="form-group">
            <label>控制器名称</label>
            <input type="text" placeholder="控制器名称" name="controller" class="form-control">
        </div>
        <div class="form-group">
            <label>方法名称</label>
            <input type="text" placeholder="方法名称" name="action" class="form-control">
        </div>
        <div class="form-group">
            <label>css图标</label>
            <input type="text" placeholder="css图标" name="css_icon" class="form-control">
        </div>
        <div class="form-group">
            <label>是否显示菜单</label>
            <select name="is_menu" class="form-control">
                <option value="0">否</option>
                <option value="1">是</option>
            </select>
        </div>
        <div class="form-group">
            <label>菜单排序</label>
            <input type="text" placeholder="菜单排序" name="weight" class="form-control">
        </div>
        <div class="form-group">
            <label>菜单等级</label>
            <input type="text" placeholder="主菜单等级" name="menu_level" class="form-control">
        </div>
        <div class="text-center">
            <input type="hidden" name="__action_type__" value="save">
            <button type="button" id="add" class="btn btn-raised btn-black">添加</button>
        </div>
    </form>
</div>

<script>
    $(function () {
        $("#add").click(function () {
            ajax.formSubmit('#addForm',function (data) {
                if(data.err){
                    alert(data.msg);
                    return false;
                }
                alert('添加成功');
                $("a[href='{:url('admin/auth/index')}']").click();
            });
        });
    });
</script>